# HCI574 - HW1 (Summer 2011)

# Before you start:
# 1) create a HW1_myname folder (for Arthur Lemming, the folder would be HW1_Arthur_Lemming)
# 2) Save as ... this file into this folder as HW1.py
# 3) Put all files for HW1 (screenshots, results file, etc.) into this HW_myname folder

# The questions for HW 1 are given below (#0 to #13).
# First, experiment inside the python shell, then write the solution
# into your HW1.py file (this file). Within the .py file, you need to put a print statement
# in front of anything you wa,t to print out, even though the python shell does not require that.
# I've given you some help (see ???s, remove the # to uncomment the line)
# Print out the exercise number followed by your answer - as an example see question 0 below,
# it first prints out a 0) (for step 0) and then a 3 (the answer to exercise 0's question).

# 0) Example:print out 3 - put the exercise number first in your print statements
print "0)", 3  # print the a 0) and the number 3. No spaces before the print!

# Deliverables:
# Run this file in Idle or Wing101 (Run - Run Module (F5)) until it runs without errors
# Past the output of the python shell into a plain text or rtf file (your "results file"), 
# save it as HW1_results.txt in your HW1 folder.
# After your run your turtle goto star, take a screenshot of the turtle graphics window and save is as
# HW1_turtle_star.jpg (or .gif or .png ...) in your HW1 folder.
#
# Zip your HW1 folder (into something like HW1_Arthur_Lemming.zip) and hand in this
# zip file into WebCT as an attachment. All HW assignment hand-ins will happen this way.

# Recap:
# Make a folder HW?_myname, put all relevant files (code file(s), results text file,
# screenshots, etc.) into that folder, zip the folder, hand in the zip file into WebCT.

# Step 1 - 1 pts
# Import the math module (math) and use dir() to show its content 
#print "1)", ???

# Step 2 - 1 pts
# show the internal help on the log10 math function  
#print "2)", ???

# Step 3 - 1 pts
#  using the functions and constant values defined by the math module,
# calculate the square-root of the log10 of Pi  
#print "3)", math.???

# Step 4 - 1 pts 
# print the result of the random() function from the random module (1 pt)
#print "4)", ???

# Step 5 - 1 pts
# in the documentation look up the minumum and maximum possible values
#    returned by the random() function  
#print "5) random() returns", ???.???, "to", ???.???
 
# Step 6 - 2 pts
# / operator: what is the difference of dividing 3 by 2 vs dividing 3 by 2.0 ? 
# What's the magic of the .0?
#print "6) The difference between 3/2 and 3/2.0 is  ???"

# Step 7 - 1 pts
# Make a list l (ell) with 3 elements, the number 1, the number 2.7 and the string
# "Monty Python", print the list  
#l = ???
#print "7)", "l contains", ???

# Step 8 - 1 pts
# print the number of elements stored in the list l (1 pt)
#print "8) The list l contains", ???, "elements"

# Step 9 - 1 pts
# Make a string s from the last element of l using the total number of elements 
# in l to get the index/offset of "last" (1 pt)
#s = l????
#print "9) s contains", s

# Step 10 - 2 pts
# 10) concatenate (glue together) the first and last letter of s 
#first_and_last = ??? + ???
#print "10) first and last letter of s are", first_and_last

# Step 11 - 2 pts
# Using slices of s (e.g. [2:4]), + and *, assemble and print "PyPyMon" 
#print "11) glued together slices", ???

# Step 12 - 2 pts
# \Give me (at least) two different ways of creating a dictionary with those two key-value pairs
# "name" : "Ames" and "population" : 50731  
#dict1 = ??? # Create dict1 from "name" : "Ames" and "population" : 50731 in one way
#print "12a) First dict", dict1
#dict2 = ??? # Create dict2 from "name" : "Ames" and "population" : 50731 in another way
#print "12a) Second dict", dict2


# Step  13 ) Random turtle goto star - 5 pts
print "13) Random turtle goto star" 
# note: as you experiment with the turtle graphics, its graphics window may appear "stuck".
# To kill the turtle graphics window, use  Python Shell -> Restart Shell (Control-F6), or
# type turtle.bye() (also see turtle.reset() and turtle.clear() )
# The turtle graphics window may initially appear in the middle or the screen, and possibly
# behind any other windows, even your editor windows (turtle are not that smart and like to hide :)
# If you have trouble getting a screenshot, move your editor out of the way before pressing Run
# 

# import the turtle package
import turtle
#turtle.speed('fastest') #uncomment if you're impatient

# setting up the canvas for you turtle to move on:
max_x = 300
max_y = 300
print "canvas x coordinates go from", -max_x, "to", max_x
print "canvas y coordinates go from", -max_y, "to", max_y
# 0,0 is the center of the canvas

# extra 1 pt:
# what are the x/y coordinates of the lower left corner of the canvas
#print "lower-left corner is at x=", ???, ", y=", ???


# make turtle go to a random x/y pair (within the min/max canvas coordinates)

for n in range(10): # start of for loop: repeat the indented block 10 times
    
    # make sure lines below are indented with 4 spaces, like this line!
    print n+1, # print out the loop counter variable's value comma means: no line feed

    # make random x and y coordinates, stay within the canvas boundaries!
    #random_coord_x = ???   
    #random_coord_y = ???     

    # make turtle go to this random x/y coordinate
    #print ": goto x/y", random_coord_x, ",", random_coord_y # print coords
    #turtle.goto(random_coord_x, random_coord_y) 
    
# end of for loop
print "did", n+1, "random gotos" # post-loop: no indent

# if the window disappears, comment in the following line to wait for your
# keyboard input:
#raw_input("Press any key to continue ...")

# Now make a screenshot of your random turtle goto star and save it as HW1_turtle_star.jpg

# Total: 21 + 1 pts
